package pac;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Testt {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        File file = new File("D://a");
        method(file,map);
        System.out.println(map);
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            System.out.println(entry);
        }
    }

    private static void method(File file, Map<String, Integer> map) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()){
                String name = file1.getName();
                String[] split = name.split("\\.");
                String s = split[split.length - 1];
                if (!map.containsKey(s)){
                    map.put(s,1);
                }else {
                    int integer = map.get(s);
                    map.put(s,integer+1);
                }
            }else {
                method(file1,map);
            }
        }
    }
}
